package com.myapp.api.mapper;

import com.myapp.api.entity.Course;
import org.apache.ibatis.jdbc.SQL;

public class CourseSqlProvider {

    public String insertSelective(Course record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("course");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getCid() != null) {
            sql.VALUES("Cid", "#{cid,jdbcType=VARCHAR}");
        }
        
        if (record.getTid() != null) {
            sql.VALUES("Tid", "#{tid,jdbcType=VARCHAR}");
        }
        
        if (record.getCname() != null) {
            sql.VALUES("Cname", "#{cname,jdbcType=VARCHAR}");
        }
        
        if (record.getCredit() != null) {
            sql.VALUES("Credit", "#{credit,jdbcType=DOUBLE}");
        }
        
        if (record.getCount() != null) {
            sql.VALUES("Count", "#{count,jdbcType=INTEGER}");
        }
        
        if (record.getCreatetime() != null) {
            sql.VALUES("CreateTime", "#{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.VALUES("UpdateTime", "#{updatetime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Course record) {
        SQL sql = new SQL();
        sql.UPDATE("course");
        
        if (record.getCid() != null) {
            sql.SET("Cid = #{cid,jdbcType=VARCHAR}");
        }
        
        if (record.getTid() != null) {
            sql.SET("Tid = #{tid,jdbcType=VARCHAR}");
        }
        
        if (record.getCname() != null) {
            sql.SET("Cname = #{cname,jdbcType=VARCHAR}");
        }
        
        if (record.getCredit() != null) {
            sql.SET("Credit = #{credit,jdbcType=DOUBLE}");
        }
        
        if (record.getCount() != null) {
            sql.SET("Count = #{count,jdbcType=INTEGER}");
        }
        
        if (record.getCreatetime() != null) {
            sql.SET("CreateTime = #{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.SET("UpdateTime = #{updatetime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}